package com.learn.worker;

import com.learn.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/08/16
 * @description ch02 工作队列消费者
 * 工作线程 worker01就是一开始的消费者
 * 自动使用轮循机制
 * 要在主方法运行的三角里面设置allow multiple instances
 */
public class Worker02 {
    public static final String QUEUE_NAME = "hello_world";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();
        channel.basicConsume(QUEUE_NAME, true, (consumerTag, message)->{
            System.out.println(new String(message.getBody()));
        }, (consumerTag)->{
            System.out.println(consumerTag);
        });
    }
}
